﻿using VIA.Foundation;
using VIA.Integration.Presentation;
using VIA.Presentation;
using VIA.Presentation.Contracts;
using VIA.SiMoJi.Domain.Inspection;
using VIA.SiMoJi.Domain.Option;
using static VT.Framework.Utils.UtilMiniDump;

namespace VIA.SiMoJi.Presentation.ViewModel
{
    [ViewModel(typeof(IBuJinPiDaiStationOptionView))]
    internal class BuJinPiDaiStationOptionViewModel : EditorViewModel<IBuJinPiDaiStationOptionView, BuJinPiDaiStationOption>
    {
        private bool isRunning;
        private readonly Inspector _inspector;
        private readonly BuJinPiDai _station;

        public IRelayCommand PMoveCommand { get; }
        public IRelayCommand NMoveCommand { get; }
        public IRelayCommand StopCommand { get; }

        public bool IsRunning { get => isRunning; set => SetProperty(ref isRunning, value); }
        public BuJinPiDaiStationOptionViewModel(IServiceProvider service, Inspector inspector) : base(service)
        {
            this._inspector = inspector;
            _station = inspector.BuJinPiDai;
            PMoveCommand = _commandFactory.Create(PositiveMove);
            NMoveCommand = _commandFactory.Create(NositiveMove);
            StopCommand = _commandFactory.Create(Stop);
        }

        private void Stop()
        {
            _station.AxisStopMove();
            IsRunning = false;
        }

        private void PositiveMove()
        {
            _station.AxisPositiveMove(null, default);
            IsRunning = true;
        }

        private void NositiveMove()
        {
            _station.AxisNagetiveMove(Option.Speed, default);
            IsRunning = true;
        }
    }
}
